<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Listagem de Planos</title>
    </h:head>
    <h:body>
        <h:form id="listPlanos">
            <fieldset>
                <legend>Planos cadastrados</legend>
                <c:choose>
                    <c:when test="#{!empty planoBean.planos}">
                        <h:dataTable value="#{planoBean.planos}" var="plano"
                                     rules="rows" border="1" binding="#{planoBean.table}">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet>
                                <h:outputText value="#{plano.id}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Plano"/>
                                </f:facet>
                                <h:outputText value="#{plano.nome}" />
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Remover" />
                                </f:facet>
                                <h:commandButton action="#{planoBean.remove}" value="Remover"
                                                 onclick="if(!confirm('Deseja remover #{plano.nome}?')) return false"/>
                            </h:column>
                        </h:dataTable>
                    </c:when>
                    <c:otherwise>
                        <h:outputText value="Não há nenhum plano cadastrado."/><br />
                    </c:otherwise>
                </c:choose>
                <h:commandButton value="Voltar" action="createPlano" />
            </fieldset>
        </h:form>
        <h:form id="principal">
                 <h:commandButton value="Principal" action="principal" />
             </h:form>
    </h:body>
</html>

